The operation followed a militant attack on a Rangers headquarters in Karachi that killed three soldiers.